package resolvers

import (
	"context"
	"happy-sudoku/graphql/models"
	"happy-sudoku/internal/model"
)

type subscriptionRootResolver struct{ *RootResolver }

func (r *subscriptionRootResolver) RoomSettingChanged(ctx context.Context) (<-chan *model.RoomSetting, error) {
	panic("not implemented")
}

func (r *subscriptionRootResolver) PlayerJoined(ctx context.Context) (<-chan *model.Player, error) {
	panic("not implemented")
}

func (r *subscriptionRootResolver) PlayerLeft(ctx context.Context) (<-chan *model.Player, error) {
	panic("not implemented")
}

func (r *subscriptionRootResolver) PlayerStatesUpdated(ctx context.Context) (<-chan *model.PlayerState, error) {
	auth := model.ForAuthContext(ctx)
	return r.roomSrv.SubscribePlayerState(ctx, auth.PlayerID)
}

func (r *subscriptionRootResolver) GameStarted(ctx context.Context) (<-chan *model.Room, error) {
	panic("not implemented")
}

func (r *subscriptionRootResolver) RoomStateChanged(ctx context.Context) (<-chan *model.Room, error) {
	auth := model.ForAuthContext(ctx)
	return r.roomSrv.SubscribeRoom(ctx, auth.PlayerID)
}

func (r *subscriptionRootResolver) GameTimeSync(ctx context.Context) (<-chan model.TimeDuration, error) {
	auth := model.ForAuthContext(ctx)
	return r.roomSrv.SubscribeGameTime(ctx, auth.PlayerID)
}

func (r *subscriptionRootResolver) RoomListUpdated(ctx context.Context) (<-chan *models.RoomListUpdatedRes, error) {
	// auth := model.ForAuthContext(ctx)
	return r.roomSrv.SubscribeRoomListUpdate(ctx, 1)
}
